Skip to content

genui: Tufte style behind a setting (charts, components, agent guidance) - #467

Draft
mjsz wants to merge 11 commits into
feat/genuifrom
feat/genui-tufte
Draft

mjsz wants to merge 11 commits into
feat/genuifrom
feat/genui-tufte

Conversation

@mjsz

@mjsz mjsz commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a Tufte style setting (tufteStyle, on by default) to genui. When it's on, charts and other data components follow Tufte's data-ink rules, and agents get a short section on how to show data. When it's off, every component renders byte for byte what feat/genui renders today, and agents get no style guidance. That keeps the change ready to offer upstream as an opt-in. This PR builds on #466, which adds the genui plugin.

Charts

  • Range frames instead of gridlines (line, area and bar): the y axis spans only the data's low to its high. It's labeled at both ends and at up to two round values between. Lines span their data; bars and areas reach zero, because they stand on it. A faint line marks zero when zero is in range. Numeric, date and time x labels get the same frame; category labels stay as they are.
  • Direct labels instead of a legend for line and area charts with 2–6 series: each series name sits at the end of its line, in the series colour, and names are pushed apart when lines end close together. Above six series, or when the names don't fit, the chart keeps its SeriesLegend. Bar charts keep their legend.
  • Pie as sorted bars: one horizontal bar per slice, largest first, each with its share and value. The "Other" grouping stays.
  • Colour: a single untoned series is drawn in ink, with the accent only on its latest point. Sparklines stay 80 × 20 and ring their lowest and highest points.

Other components (no parameter or API changes)

  • Table: columns of numbers written as text ("210 ms", "18.2k", "−31%") are right-aligned in tabular figures, and rows are denser.
  • Badge: no pill. A dot appears only when the tone means something, followed by the word at the size of the surrounding text.
  • Gauge: a bullet bar replaces the dial: a thin bar of ink over a faint range, with the value and the range's ends as text. Progress uses the same bar.
  • Card: the title is set in plain type. A nested card gets a hairline rule instead of a filled box. The outer card keeps its hairline frame, so a block still reads as one unit in the chat.
  • Callout: the background wash and the icon are gone, because they only repeated the tone. A rule in the tone's colour carries it instead.
  • SegmentedBar: untoned parts use shades of one hue instead of a hue each, and there's no track behind the bar. Toned parts keep their tone.
  • List: icons appear without a tile behind them, and are dropped when every row has the same icon.
  • Treemap: all groups use one hue. The success and warning hues used to mean only "another folder" here.
  • Left alone:
    • Metric and KeyValue already show label, value and note with no boxes or fills.
    • CalendarHeatmap and the heatmap Chart already use one hue from the theme, from light to full.
    • Scatter, radar, funnel, histogram and box charts have no shared axis code to change.

Agent guidance

With the setting on, sessions that get the UI instructions also get "Inline UI: Tufte style" (1,025 characters), contributed after the code-work section:

# Inline UI: Tufte style
Tufte style is on: show data the way Edward Tufte would. This refines the Inline UI section.
- Context: compare every number with something (prior period, target, peer). Put the comparison in the Metric's note ("+12% vs May", "target 99.9%") or a Sparkline beside it.
- Label the graphic, not a key: units on every value, series named, and a note on the point that matters, so the block reads without the prose.
- Small multiples: several entities or series → a Grid of small Charts, one each, or a Table with a Sparkline per row, never one crowded Chart.
- Density: a lone number belongs in the sentence, not in a Metric. Several facts about one thing → one Table or KeyValue, not a Card each.
- Ink only for data: no decorative Icon or Badge; a tone only where it means good, bad or over a limit.
- Every Chart, Table and Metric says where its numbers came from: Load(path) or source:.
- Mechanism: when the user asks why, show what causes the number in a Diagram, not only the number.

The section would otherwise conflict with or repeat some lines in AGENT_INSTRUCTIONS. While the setting is on, those lines are swapped, the same way AGENT_INSTRUCTIONS_WEB_OFF swaps the Map example (TUFTE_SWAPS):

  • "In doubt, add the block." → "In doubt, add one block."
  • "Wrap each block in one Card." → "Wrap each block in one Card, titled with its finding."
  • "- series → Chart, many → Grid of small Charts;" → "- series → Chart;" (the section covers small multiples in full)

All four rule variants (Tufte style on or off × web lookups on or off) fit under the 4,096-character cap: 4,093, 4,091, 4,089 and 4,087 characters. With Automatic UI instructions off, the /ui skill can't read the setting, so it carries the section behind a check of bb plugin config genui, with the two behavioural swaps spelled out.

The shape list in AGENT_INSTRUCTIONS (both variants) also steers shares to SegmentedBar or a sorted bar instead of a pie. To fit that clause, the list drops some articles.

How it's built

  • server.ts declares STYLE_SETTINGS next to MOTION_SETTINGS. The page reads it the same way motion.ts reads animations, keeping the off state in localStorage. The server reads it to choose the instructions.
  • ui/components/tufte.tsx holds the hook and the shared Tufte pieces: range frames, direct labels, share bars, BulletBar, numberLike and oneHueShade. Each component calls useTufteStyle() and branches only where the two styles differ, so no component is forked.
  • chartMath.ts holds the pure frame and label math: rangeTicks, frameLabelIndices and spreadLabels.

Toggle

bb plugin config genui set tufteStyle false   # everything exactly as before, no guidance
bb plugin config genui set tufteStyle true    # Tufte style (default)

Visual changes apply live. Guidance changes reach new sessions.

Things to check

  • The wording of the section and of the swapped lines.
  • The shape-list article trims, which make room for the pie clause.
  • The pie steer applies with the setting off too.
  • Chart has no y-range parameter, so the charts in a Grid scale independently. The guidance says "small Charts" and doesn't promise a shared scale.

Tests

  • Chart.test.tsx and tufteStyle.test.tsx render the gallery examples of every chart and component this PR touches, plus extra chart shapes, with the setting off. They compare the markup to baseline files written by the renderers before each layer changed them. Other cases in the same files check what each component drops with the setting on.
  • chartMath.test.ts covers the frame and label math.
  • instructions.test.ts covers the cap for every variant, the 2,000-character section budget, the swaps and the skill sync.
  • server.test.ts covers all eight combinations of automaticInstructions, tufteStyle and webLookups, plus a live toggle.
  • npm run typecheck: clean
  • npm test: 101 files, 1,221 tests passed
  • bb plugin build: succeeds
  • Screenshots of every touched gallery example in light and dark, with the setting on and off, reviewed by eye.

🤖 Generated with Claude Code

mjsz and others added 11 commits December 1, 2026 14:24
… baseline

Declares `tufteCharts` (label "Tufte charts", on by default) next to
`animations` and reads it in the page the same way: `useSettings`, with
the off state kept in localStorage so a fresh page draws in the chosen
style before BB answers. Nothing reads it yet.

Chart.test.tsx draws each chart gallery example, plus shapes the gallery
lacks, with the setting off and compares the markup with files written
by the renderer as it is now. Later commits must leave them unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the Tufte charts setting on, line, area and bar charts drop their
dashed gridlines. The y axis becomes a range frame: a line from the
ink's low to its high, ticked and labeled at both ends and at up to two
round values between. Lines span their data; bars and areas stand on
zero, so their frame reaches it. A faint line stays at zero when zero is
in range. Numbers, dates and times along the bottom get the same
treatment; categories keep every label that fits.

The tick math (rangeTicks, frameLabelIndices) is pure and tested in
chartMath.ts; the frame's drawing lives in tufte.tsx.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…egend

With the Tufte charts setting on, a line or area chart with two to six
series drops its legend and writes each series' name at the end of its
line (a stacked area at the middle of its band), in the series' color.
Names of lines that end close together are pushed apart, as little as
they need, by spreadLabels in chartMath.ts. The chart keeps the legend
when there are more than six series, the names would take more than a
third of the width, or the plot is too short to set them apart. Bar
charts keep their legend.

Also widens the least gap between range-frame labels to 22 px: at 14 px
a round value next to an end (40 GB under 46 GB) read as clutter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the Tufte charts setting on, Chart("pie", …) draws one horizontal
bar per slice, largest first, each named and labeled with its share and
value. Lengths along one baseline compare far better than angles, and
the labels make a legend and per-slice colors unnecessary, so every bar
is one muted ink. The slices are the donut's own (pieSlices): past
eight, the rest fold into "Other", which stays last and quieter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arts

With the Tufte charts setting on, an untoned single-series line or area
is drawn in the foreground ink and its latest point keeps the accent;
single-series bars are one muted ink. Several series and toned series
keep their colors: there color tells things apart or means something.

A neutral sparkline is drawn in ink with its latest point in the accent,
and every sparkline rings its lowest and highest points (left out when
the latest point is the extreme, and for a flat line). It stays 80 by
20 pixels.

Two follow-ups from the visual check: share bars say a value once when
it is already a percentage (unit "%"), and leave room for both labels
after the longest bar; a framed x axis names only labels that fit whole.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first line of the shape list in AGENT_INSTRUCTIONS now says many
series go in a Grid of small Charts, and shares go in a SegmentedBar or
a sorted bar, never a pie. The section was 10 characters under BB's
4,096-character cap, so the shape list drops its articles ("a level vs
a limit", "options vs criteria", "file tree", …) to make room; it is
now 4,093 characters (4,091 with web lookups off). skills/ui/SKILL.md
carries the same text.

Also documents the Tufte charts setting in docs/architecture.md and the
changelog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The setting is about to cover tables, metrics, cards and meters and to
add guidance for agents, so `tufteCharts` ("Tufte charts") becomes
`tufteStyle` ("Tufte style"), with a description that says what it
changes in each. `useTufteCharts` becomes `useTufteStyle`, and the
localStorage key and the docs follow. No migration: the setting has not
shipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tufteStyle.test.tsx draws the gallery examples of Table, Metric, Card,
Gauge, Progress, Badge, Callout, SegmentedBar, KeyValue, List,
CalendarHeatmap, the heatmap Chart and Treemap with the Tufte style
setting off, and compares the markup with files written by the
renderers as they are now. Later commits must leave them unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fte style

With the Tufte style setting on, components shed ink that carries no
data. No component's parameters change.

- Table: columns of numbers written as text ("210 ms", "18.2k", "−31%")
  are right-aligned in tabular figures like columns of numbers, and
  rows are denser.
- Badge: no pill; a dot only where the tone means something, then the
  word at the size of the text around it.
- Gauge: a bullet bar (a thin bar of ink over a faint band, the value and
  the range's ends as text) instead of a half-disc dial. Progress draws
  the same bar.
- Card: the title in plain type; a nested card is a hairline over the
  tile instead of a filled box. The outer card keeps its hairline frame,
  so a block still reads as one unit in the chat.
- Callout: no wash and no icon, which only repeated the tone; a rule in
  the tone's color carries it.
- SegmentedBar: untoned parts in shades of one hue instead of a hue each,
  and no track behind the parts. Toned parts keep their tones.
- List: icons without a tile, and none when every row has the same one.
- Treemap: every group in one hue. Success and warning hues meant
  "another folder" there, and good and bad everywhere else.

Left alone: Metric and KeyValue (already label, value and note without
boxes or fills), CalendarHeatmap and the heatmap Chart (already one
hue from the theme, light to full).

tufteStyle.test.tsx holds the setting-off markup of every touched
component's gallery examples (and the Sparkline table, whose number
column now aligns) against the baselines, and checks what each
component sheds with the setting on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the Tufte style setting on, sessions that get the UI instructions
also get "Inline UI: Tufte style" (1,025 characters), contributed after
the code-work section and so right before the Inline UI rules it
refines. It asks for numbers in context (a comparison in the Metric's
note or a Sparkline), labels on the graphic instead of a key, small
multiples instead of one crowded Chart, a lone number in the sentence
instead of a Metric, ink only for data, a source for every Chart, Table
and Metric, and a Diagram for why.

Rules it would contradict or repeat are swapped while it is on,
following the web-lookups variant: "In doubt, add the block." becomes
"In doubt, add one block.", "Wrap each block in one Card." gains
"titled with its finding", and the shape list drops the small-multiples
clause the section says in full. Every variant (Tufte style and web
lookups, on and off) stays under the 4,096-character cap.

With automatic instructions off, the /ui skill carries the section
behind a check of the setting, with the swaps spelled out. Tests cover
the eight combinations of automaticInstructions, tufteStyle and
webLookups, a live toggle, the swaps and the skill's sync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The changelog and docs/architecture.md now cover what Tufte style does
beyond charts and the guidance it adds for agents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mjsz mjsz changed the title genui: Tufte chart style behind a setting (range frames, direct labels, no pies) genui: Tufte style behind a setting (charts, components, agent guidance) Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant